package com.noahsloan.nutils.bytes;

import java.io.IOException;

/**
 * Thrown when calling code was expecting more bytes but encountered the End Of
 * Stream marker.
 * 
 * @author Noah Sloan
 * 
 */
public class UnexpectedEndOfStreamException extends IOException {
    private static final long serialVersionUID = 8104751842812708102L;

    private int expected; // see getExpected()

    /**
     * 
     * @param expected
     *            the number of bytes that could not be read.
     * @see #getExpected()
     */
    public UnexpectedEndOfStreamException(int expected) {
        this.expected = expected;
    }

    /**
     * 
     * @return the number of bytes that were not there. i.e. if the calling code
     *         was expecting 4 bytes but only read 3 before end of stream,
     *         expected will be 1.
     */
    public int getExpected() {
        return expected;
    }
}
